﻿    using Microsoft.VisualBasic.ApplicationServices;
using System.Windows;
using FixSoft.CloudGround;
using System;
public class EntryPoint
{
    /// <summary>
    /// Application Entry Point.
    /// </summary>
    [STAThread]
    public static void Main(string[] args)
    {
        System.Windows.Forms.Application.EnableVisualStyles();
        SingleInstanceManager manager = new SingleInstanceManager();
        manager.Run(args);
    }
}


public class SingleInstanceManager : WindowsFormsApplicationBase
    {
        App AppInstance;

        public SingleInstanceManager()
        {
            this.IsSingleInstance = true;
        }

        protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
        {
            // First time app is launched
            AppInstance = new App();
            AppInstance.InitializeComponent();
            AppInstance.Run();
            return false;
        }

        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
        {
            // Subsequent launches
            base.OnStartupNextInstance(eventArgs);
            AppInstance.Activate();
        }
    }
